Skip to main content

System Variables

Built-in System Variables Usage in JSON Parameters

When calling functions via JSON in this system, you can include special built-in system variables in the parameters field. These variables are placeholders that the system will automatically replace with dynamic content during execution. Here is a list of available system variables and how to use them in your JSON payload:

  • $TOPIC_PATH: Gets replaced with the current path of the topic being processed.
  • $SELECTION_HTML: Inserts the current HTML selection.
  • $SELECTION_TEXT: Inserts the current text selection.
  • $TOPIC_XHTML: Inserts the XHTML content of the current topic.
  • $TOPIC_TEXT: Inserts the plain text content of the current topic.
  • $TOPIC_MARKDOWN: Inserts the markdown representation of the topic's content.
  • $CONTENT_FOLDER: If using with a Flare project, it inserts the path to the content folder.
  • $PROJECT_FOLDER: If using with a Flare project, it inserts the path to the project folder.
  • $TOC_FOLDER: If using with a Flare project, it includes the path to the table of contents folder.
  • $USER: Inserts the username of the person executing the command.
  • $DATE: Replaces with the current date in yyyy-MM-dd format.
  • $TIME: Inserts the current time in HH:mm:ss format.
  • $CLIPBOARD: Inserts the current text stored in the clipboard.
  • $GUID: Replaces with a new globally unique identifier (GUID).

Example Function Call Using Built-in Variables

Below is a JSON example that incorporates some of these system variables within a function call:

{
"function_name": "SOME_FUNCTION",
"parameters": [
"$SELECTION_HTML",
"Edited on $DATE at $TIME by $USER"
],
"output": "$Result"
}

In this example:

  • "$SELECTION_HTML" will be replaced with the HTML content that the user has selected.
  • "Edited on $DATE at $TIME by $USER" will have $DATE, $TIME, and $USER replaced with the current date, current time, and the username of the user executing the command, respectively.
  • The output will be stored in a variable named Result.

Always ensure the function you are calling expects and appropriately handles these system variables. The system replaces each variable with the corresponding dynamic content, and the function must be able to process that content.

Remember to format these variables exactly as shown, with a leading $ sign and surrounded by " when included within strings, to ensure they are correctly recognized and replaced by the system during execution.